//
//  AppDelegate.m
//  CKApp
//
//  Created by CC on 2020/8/25.
//  Copyright © 2020 This Moment. All rights reserved.
//

#import "AppDelegate.h"
#import "LcFoundation.h"
#import "MainWindowRootManager.h"
#import "UserManager.h"
#import "JVERIFICATIONService.h"
#import "ThirdPartyConstants.h"
#import <AMapFoundationKit/AMapFoundationKit.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

+ (AppDelegate*)sharedInstance {
  id<UIApplicationDelegate> delegate = [UIApplication sharedApplication].delegate;
  LC_CHECK_TRUE([delegate isKindOfClass:AppDelegate.class]);
  return (AppDelegate*)delegate;
}

- (BOOL)application:(UIApplication*)application
    didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
// Override point for customization after application launch.
#ifdef DEBUG
  self.launchOptions = launchOptions;
#endif
  UIWindow* mainWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  [MainWindowRootManager sharedInstance].mainWindow = mainWindow;
  self.window = mainWindow;
  self.window.backgroundColor = LC_COLOR_BLACKGROUND_GRAY;
  [self.window makeKeyAndVisible];
  [UserManager sharedInstance];
  [[MainWindowRootManager sharedInstance] startAppMainWindow];
  [self registThirdLib];
  return YES;
}

- (void)applicationWillResignActive:(UIApplication*)application {
  self->_isForeground = NO;
}

- (void)applicationDidEnterBackground:(UIApplication*)application {

}

- (void)applicationWillEnterForeground:(UIApplication*)application {
  
}

- (void)applicationDidBecomeActive:(UIApplication*)application {
  self->_isForeground = YES;
}

- (void)applicationWillTerminate:(UIApplication*)application {

}

#pragma mark - ThirdLib
- (void)registThirdLib {
  //集成极光认证sdk
  JVAuthConfig *config = [[JVAuthConfig alloc] init];
  config.appKey = JVERAFICATION_APPKEY;
  [JVERIFICATIONService setupWithConfig:config];
  [JVERIFICATIONService preLogin:5000 completion:^(NSDictionary *result) {

  }];
#if DEBUG
  [JVERIFICATIONService setDebug:YES];
#endif
  // 地图
  [AMapServices sharedServices].apiKey = GAODE_MAP_APPKEY;
}

@end
